#include "widget.h"
#include "ui_widget.h"
#include <QPainter>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

void Widget::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    painter.drawEllipse(QPoint(100, 200), 50, 50);// 绘圆

    painter.translate(100, 100); // 让画家移动
    painter.save(); // 保存画家状态

    painter.drawEllipse(QPoint(100, 200), 50, 50); // 绘圆

    painter.translate(100, 100); // 让画家移动
    painter.restore();

    QPen pen;
    pen.setColor(QColor(255, 0, 0));// 设置成红色的线条
    pen.setWidth(5); // 设置线条的粗细.
    pen.setStyle(Qt::DashLine);// 设置线条的风格
    painter.setPen(pen);// 让 painter 对象应用 pen 对象

    painter.drawEllipse(QPoint(100, 200), 50, 50);// 绘圆
}

Widget::~Widget()
{
    delete ui;
}

